#!/usr/bin/perl

open(R_VERSION, "grep 'Version' DESCRIPTION |");
$version = <R_VERSION>;
close(R_VERSION);

$version =~ /(\d+)\.(\d+)\.(\d+)/;
$r_major = $1;
$r_minor = $2;
$r_mod = $3;

open(GIT_VERSION, "git describe --tags |");
$git = <GIT_VERSION>;
close(GIT_VERSION);

$git =~ /v(\d+)\.(\d+)\.(\d+)/;
$git_major = $1;
$git_minor = $2;
$git_mod = $3;

if ($r_major > $git_major || $r_minor > $git_minor || $r_mod > $git_mod) {
	$new_version = "v$r_major.$r_minor.$r_mod";
} else {
	$new_version = "";
}

print($new_version);
